package com.kly.user.db.dao.impl;
import com.fqgj.common.base.AbstractBaseMapper;
import com.fqgj.common.utils.StringUtils;
import com.google.common.collect.Maps;
import com.kly.user.db.dao.UserChatListDao;
import com.kly.user.db.entity.UserChatListEntity;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;

/**
* User: linqu
* Date: 2024-05-30
* Time: 16:36:11.764
*/

@Repository
public class UserChatListDaoImpl extends AbstractBaseMapper<UserChatListEntity> implements UserChatListDao {

    @Override
    public Integer addChat(String chatterCode, String userCode, String modelCode, Integer sendTo) {
        if (StringUtils.isEmpty(chatterCode)) {
            return 0;
        }
        final HashMap<String, Object> params = Maps.newHashMap();
        params.put("chatterCode", chatterCode);
        params.put("userCode", userCode);
        params.put("modelCode", modelCode);
        params.put("sendTo", sendTo);
        return this.getSqlSession().insert(this.getStatement("addChat"), params);
    }

    @Override
    public List<UserChatListEntity> listOnlineUserChats(String chatterUserCode, String modelUserCode) {
        final HashMap<String, Object> params = Maps.newHashMap();
        params.put("chatterUserCode", chatterUserCode);
        params.put("modelUserCode", modelUserCode);
        return this.getSqlSession().selectList(this.getStatement("listOnlineUserChats"), params);
    }
}